home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1996 #15
/
Monster Media Number 15 (Monster Media)(July 1996).ISO
/
os2
/
srefv112.zip
/
SREFPRC1.ZIP
/
DOVIRT.SRF
< prev
next >
Wrap
Text File
|
1996-05-11
|
5KB
|
176 lines
/******************************************************************************/
/* ------------------------------------------------------------------------ */
/* DO_VIRTUAL_FILE: Convert from URL to file name-- add virtual directory of data directory.
ddir : data directory
sel : request string (after sre-filter has modified it)
virtual_dir : List of virtual file replacement possiblities.
virtual_dir.label.nv virtual_dir.dir.nv virtual_dir.subok
Return: file name (with drive/directory) or 0 if not found/not allowed
*/
sref_do_VIRTUAL:
parse upper arg ddir,action , macrospace_input ,virtual_file
macrospace_input=strip(macrospace_input)
virtual_file=strip(virtual_file)
ddir=strip(ddir)
action=strip(action)
if abbrev(translate(macrospace_input),'N')=1 then macrospace_input=0
/* check for illegal action (with .. in it) */
if pos("..",action)>0 then return 0
filelines.0=0
action=translate(action) ; action=strip(action,'l','/')
call get_virtfile 1
if filelines.0=0 then do
return 0 /*let caller figure out what to do */
/* like this. ..
t1=translate(ddir,'\','/') ;
tryf=strip(t1,'t','\')||'\'||action
return tryf
*/
end
gotit=0
do ii =1 to filelines.0
aline=filelines.ii
parse upper var aline alabel adir
subdirs=0
ifoo=pos('*',adir)
if ifoo>0 then do
subdirs=1
adir=delstr(adir,ifoo)
end
alabel=strip(translate(strip(alabel),'/','\'),,'/')||'/'
adir=strip(translate(strip(adir),'\','/'),'t','\')||'\'
mdir=filespec('p',adir)
mdrv=filespec('d',adir)
if drv="" then drv=filespec('d',ddir)
adir=mdrv||mdir
/* subdirs: allow subdirectory acces
alabel: the abbrev to match to
adir: The dir to use instead of alabel
*/
if abbrev(action,alabel)=1 then do
t1=delstr(action,1,length(alabel))
t1=translate(t1,'\','/')
tryfile=adir||t1
if subdirs=1 then do
gotit=1
leave
end
else do
if pos('\',t1)>0 then do
iterate /* violation of no subdirs */
end
else do
gotit=1
leave
end
end
end
end
/* append to data dir ? */
if gotit=0 then do
t1=strip(strip(translate(ddir,'\','/')),,'\')||'\'
action=translate(action,'\','/')
action=strip(action,'l','\')
tryfile=t1||action
end
tryfile=translate(tryfile,'\','/')
if gotit=1 then
say " Virtual directory replacement yields: " tryfile
return tryfile /* success */
/* ---------------------------------------------- */
get_virtfile:
macrodate=0 ; filedate=0
crlf='0d0a'x
if macrospace_input=0 then /* if no macro space input */
signal no_macro1
signal on error name no_macro1 /* which macro */
signal on syntax name no_macro1
gotit=0 ; macrodate=0
somestuff=sref_macro_virtual()
if somestuff<>0 then
parse var somestuff macrodate "," somestuff
else
macrodate=0
gotit=1
no_macro1:
signal off syntax ; signal off error ;
if gotit=1 then signal macrookay
/* not in marospace, read from file ? */
if virtual_file="" then do /* nowhere! */
filelines.0=0
return 0
end
say " VIRTUAL files not in macrospace, trying: " virtual_file
macrookay: /* in macro space, or virtual_file exists */
signal off error ; signal off syntax
/* get date of file */
if virtual_file<>"" then do
eek=sysfiletree(translate(virtual_file,'\','/'),'gosh','FT')
if gosh.0=0 then do /* no user defined replacement strings */
say " Missing or unavailable virtual dir file = " virtual_file
filelines.0=0
return 0
end
parse var gosh.1 atime .
filedate=sref_juldate('F',atime)
end
else do /* no file, force use of macrospace */
filedate=-1
end
/* use newer one */
if filedate>=macrodate then do /* if file newer then macrospace, use file */
ause=fileread(virtual_file,'templines',,'e')
if (ause=0) then do /*no such file,*/
say " Missing or unavailable initialization file: " atype
filelines.0=0
return 0
end /* so no user defined replacement strings*/
end
else do /* use stuff stored in macro space */
i1=0
do until somestuff=""
i1=i1+1
parse var somestuff templines.i1 (crlf) somestuff
end
templines.0=i1
end
iff=0
do mm=1 to templines.0
aline=translate(strip(templines.mm))
if left(aline,1)=';' | aline="" then iterate
iff=iff+1
filelines.iff=templines.mm
end
filelines.0=iff
return iff